}
// Notification:
-// @id: the notification's id
// @source: the notification's Source
// @title: the title
// @banner: the banner text
// of the notification (as with addBody()) when the banner is expanded.
// In this case, if @banner is too long to fit in the single-line mode,
// the notification will be made expandable automatically.
-function Notification(id, source, title, banner, bannerBody) {
- this._init(id, source, title, banner, bannerBody);
+function Notification(source, title, banner, bannerBody) {
+ this._init(source, title, banner, bannerBody);
}
Notification.prototype = {
- _init: function(id, source, title, banner, bannerBody) {
- this.id = id;
+ _init: function(source, title, banner, bannerBody) {
this.source = source;
this._bannerBody = bannerBody;
this.urgent = false;
this._notificationQueue.splice(index, 1);
},
- _getNotification: function(id, source) {
- if (this._notification && this._notification.id == id)
- return this._notification;
-
- for (let i = 0; i < this._notificationQueue.length; i++) {
- if (this._notificationQueue[i].id == id && this._notificationQueue[i].source == source)
- return this._notificationQueue[i];
- }
-
- return null;
+ _hasNotification: function(notification) {
+ if (this._notification == notification)
+ return true;
+ return this._notificationQueue.indexOf(notification) != -1;
},
lock: function() {
if (notification == this._summaryNotification)
return;
- if (this._getNotification(notification.id, source) == null) {
+ if (!this._hasNotification(notification)) {
notification.connect('destroy',
Lang.bind(this, this.removeNotification));
if (notification == null) {
id = nextNotificationId++;
- notification = new MessageTray.Notification(id, source, summary, body, true);
+ notification = new MessageTray.Notification(source, summary, body, true);
this._currentNotifications[id] = notification;
notification.connect('dismissed', Lang.bind(this,
function(n) {
- this._emitNotificationClosed(n.id, NotificationClosedReason.DISMISSED);
+ this._emitNotificationClosed(id, NotificationClosedReason.DISMISSED);
}));
notification.connect('destroy', Lang.bind(this,
function(n) {
Main.messageTray.add(this);
if (!this._notification)
- this._notification = new Notification(this._targetId, this);
+ this._notification = new Notification(this);
},
_messageReceived: function(channel, id, timestamp, sender,
}
};
-function Notification(id, source) {
- this._init(id, source);
+function Notification(source) {
+ this._init(source);
}
Notification.prototype = {
__proto__: MessageTray.Notification.prototype,
- _init: function(id, source) {
- MessageTray.Notification.prototype._init.call(this, id, source, source.title);
+ _init: function(source) {
+ MessageTray.Notification.prototype._init.call(this, source, source.title);
this._responseEntry = new St.Entry({ style_class: 'chat-response' });
this._responseEntry.clutter_text.connect('activate', Lang.bind(this, this._onEntryActivated));
source.connect('destroy', Lang.bind(this, function() { delete this._sources[appId]; }));
}
- let notification = new MessageTray.Notification(window.get_startup_id(), source, this._getTitle(app, window), this._getBanner(app, window), true);
+ let notification = new MessageTray.Notification(source, this._getTitle(app, window), this._getBanner(app, window), true);
source.notify(notification);
window.connect('notify::title', Lang.bind(this, function(win) {